<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>订单资料</title>
		<link rel="stylesheet" href="../../css/base.css" />
		<link rel="stylesheet" href="../../css/common.css" />
		<!-- Bootstrap Core CSS -->
		<link href="../../sbadmin/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
		<!-- MetisMenu CSS -->
		<link href="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
		<!-- DataTables CSS -->
		<link href="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css" rel="stylesheet">
		<!-- Custom CSS -->
		<link href="../../sbadmin/dist/css/sb-admin-2.css" rel="stylesheet">
		<!-- Custom Fonts -->
		<link href="../../sbadmin/bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
		<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
		<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
		<!--[if lt IE 9]>
	<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
	<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
		<style>
			body {
				padding: 0 15px !important;
			}
		</style>
	</head>

	<body style="background:#FFF;">
		<div class="comm-tt-font pr">
			会员信息 > 会员详情
		</div>
		<div class="zl-ccbox">
			<div class="zl-cctt">
				<ul class="zl-list-ul clb">
					<li>
						<a href="personalMsg.html">个人资料</a>
					</li>
					<li>
						<a href="babyMsg.html">宝宝资料</a>
					</li>
					<li>
						<a href="order.html" class="cur">订单</a>
					</li>
				</ul>
			</div>
		</div>
		<div class="bars-box pr" style="width: 100%;overflow-x: scroll;">
			<div class="export">
				<span class="exptxt fl"></span>
			</div>
			<div class="panel-body" style="padding-top: 0 !important;width: 2100px;">
				<div class="dataTable_wrapper" id="app">
					<table class="table table-striped table-bordered table-hover" id="dataTables-example">
						<thead>
							<tr>
								<th>订单号</th>
								<th>第三方流水号</th>
								<th>商品名</th>
								<th>商品分类</th>
								<th>销售类型</th>
								<th>收货地址</th>
								<!--<th>会员姓名</th>
								<th>会员手机号</th>-->
								<th>销售门店</th>
								<th>应收金额</th>
								<th>实付金额</th>
								<th>支付方式</th>
								<th>销售方式</th>
								<th>支付状态</th>
								<th>支付交易时间</th>
								<th>截至有效期</th>
								<th>订单状态</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody id="list-td">

						</tbody>
					</table>
				</div>
				<!-- /.table-responsive -->
			</div>
			<div class="no-tit">
				<img class="no-pic" src="../../img/error.jpg" />
				<p class="no-txt">没有符合筛选条件的记录</p>
			</div>
		</div>
		<!-- jQuery -->
		<script src="../../sbadmin/bower_components/jquery/dist/jquery.min.js"></script>
		<!-- Bootstrap Core JavaScript -->
		<script src="../../sbadmin/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<!-- Metis Menu Plugin JavaScript -->
		<script src="../../sbadmin/bower_components/metisMenu/dist/metisMenu.min.js"></script>
		<!-- DataTables JavaScript -->
		<script src="../../sbadmin/bower_components/datatables/media/js/jquery.dataTables.min.js"></script>
		<script src="../../sbadmin/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js"></script>
		<!-- Custom Theme JavaScript -->
		<script src="../../sbadmin/dist/js/sb-admin-2.js"></script>
		<script src="../../js/layer/layer.js"></script>
		<script src="../../js/common.js"></script>
		<!-- Page-Level Demo Scripts - Tables - Use for reference -->
	</body>
	<script>
		var isType = localStorage.getItem("isType");
		var memTel = localStorage.getItem("localTel");
		getList("", memTel, "", "", "", "", "", "", "")

		function getList(name, phone, city, store, gdsName, gdsType, saleType, orderNum, xsDate) {
			$("#dataTables-example").dataTable().fnDestroy();
			var post_data = {
				"orderDetail": {
					"outTradeNo": orderNum,
					"receiverName": name,
					"receiverPhone": phone,
					"saleType": saleType,
					"skuCategory": gdsType,
					"skuName": gdsName,
					"storeCityId": city,
					"storeId": store
				},
				"startDate": xsDate
			}
			$.ajax({
				url: "https://order.wz1996.wang/wzbg/order/query",
				type: 'post',
				contentType: 'application/json',
				data: JSON.stringify(post_data),
				beforeSend: function(request) {
					request.setRequestHeader("token", localStorage.getItem("token"));
				},
				success: function(data) {
					console.log(data);
					if(data.code == "1") {
						var html = "";
						for(var i = 0; i < data.data.length; i++) {
							html += "<tr class='odd gradeX'>";
							html += "<td>" + data.data[i].outTradeNo + "</td>";
							html += "<td>" + data.data[i].batch + "</td>";
							html += "<td>" + data.data[i].skuName + "</td>";
							if(data.data[i].skuCategory == 2) {
								html += "<td>儿童</td>";
							} else if(data.data[i].skuCategory == 3) {
								html += "<td>亲子</td>";
							} else if(data.data[i].skuCategory == 4) {
								html += "<td>孕妇</td>";
							} else if(data.data[i].skuCategory == 5) {
								html += "<td>全家福（三代）</td>";
							}
							html += "<td>" + data.data[i].saleType + "</td>";
							if(data.data[i].receiverAddress == "" || data.data[i].receiverAddress == null || data.data[i].receiverAddress == undefined) {
								html += "<td>--</td>";
							} else {
								html += "<td>" + data.data[i].receiverAddress + "</td>";
							}
							/*html += "<td>" + data.data[i].receiverName + "</td>";
							html += "<td>" + data.data[i].receiverPhone + "</td>";*/
							if(data.data[i].storeName == "" || data.data[i].storeName == null || data.data[i].storeName == undefined) {
								html += "<td>--</td>";
							} else {
								html += "<td>" + data.data[i].storeName + "</td>";
							}
							html += "<td>" + data.data[i].price + "</td>";
							html += "<td>" + data.data[i].actualPayedPrice + "</td>";
							html += "<td>" + data.data[i].payType + "</td>";
							if(data.data[i].isOnline == "1") {
								html += "<td>线上</td>";
							} else {
								html += "<td>线下</td>";
							}
							if(data.data[i].status == "1" || data.data[i].status == "3") {
								html += "<td>已支付</td>";
							} else {
								html += "<td>--</td>";
							}
							html += "<td>" + data.data[i].createTime + "</td>";
							html += "<td>" + data.data[i].expired + "</td>";
							var expired = data.data[i].expired;
							var myDate = new Date(); //获取系统当前时间
							var mytime = myDate.toLocaleString(); //获取当前时间
							var oDate1 = new Date(expired);
							var oDate2 = new Date(mytime);
							if(data.data[i].status == "3") {
								html += "<td>停止</td>";
							} else if(data.data[i].status == "1") {
								html += "<td>有效</td>";
							} else if(oDate1.getTime() < oDate2.getTime()) {
								html += "<td>过期</td>";
							}
							if(isType != "1") {
								html += "<td><a href='orderDetail.html' class='orderMdetail' odStoreName='" + data.data[i].storeName + "' skuid='" + data.data[i].skuId + "' imgSrc='" + data.data[i].skuImageUrl + "' id='" + data.data[i].id + "'>详情</a></td>";
							} else {
								if(data.data[i].status == "3") {
									html += "<td><a href='orderDetail.html' class='orderMdetail' odStoreName='" + data.data[i].storeName + "' skuid='" + data.data[i].skuId + "' imgSrc='" + data.data[i].skuImageUrl + "' id='" + data.data[i].id + "'>详情</a><a href='javascript:void(0)' class='ml10 qiY' id='" + data.data[i].id + "'>启用</a></td>";
								} else {
									html += "<td><a href='orderDetail.html' class='orderMdetail' odStoreName='" + data.data[i].storeName + "' skuid='" + data.data[i].skuId + "' imgSrc='" + data.data[i].skuImageUrl + "' id='" + data.data[i].id + "'>详情</a><a href='javascript:void(0)' id='" + data.data[i].id + "' class='ml10 ting'>停用</a></td>";
								}
							}

							html += "</tr>";
						}
						$("#list-td").html(html);
						$('#dataTables-example').DataTable({
							responsive: false,
							bLengthChange: false,
							bSort: true,
							paging: true,
							bFilter: true,
							searching: false,
							bInfo: true,
							bAutoWidth: true,
							"oLanguage": {
								"sLengthMenu": "每页显示 _MENU_ 条记录",
								"sZeroRecords": "抱歉， 没有找到",
								"sInfo": "从 _START_ 到 _END_ /共 _TOTAL_ 条数据",
								"sInfoEmpty": "没有数据",
								"sInfoFiltered": "(从 _MAX_ 条数据中检索)",
								"oPaginate": {
									"sFirst": "首页",
									"sPrevious": "前一页",
									"sNext": "后一页",
									"sLast": "尾页"
								},
								"sSearch": "查询条件:",
								"sZeroRecords": "没有检索到数据",
								"sProcessing": "<img src='./loading.gif' />"
							}
						});
					} else if(data.code == "-1") {
						layar(data.msg);
						setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
					} else {
						layar(data.msg);
					}

				},
				error: function(e) {
					errcode(e);
				}
			});

		}

		$("#list-td").on("click", ".orderMdetail", function() {
			var odetailskuId = localStorage.setItem("odetailskuId", $(this).attr("id"));
			var orderImg = localStorage.setItem("orderImg", $(this).attr("imgSrc"));
			var skuid = localStorage.setItem("skuid", $(this).attr("skuid"));
			var odStoreName = localStorage.setItem("odStoreName", $(this).attr("odStoreName"));
		})
		$("#list-td").on("click", ".ting", function() {
			var orderId = $(this).attr("id");
			layer.confirm('您确定停用吗？', {
				btn: ['确定', '取消'], //按钮
				offset: '25%'
			}, function(index) {
				$.ajax({
					url: "https://order.wz1996.wang/wzbg/order/invalid/" + orderId,
					type: 'put',
					beforeSend: function(request) {
						request.setRequestHeader("token", localStorage.getItem("token"));
					},
					contentType: 'application/json',
					success: function(data) {
						console.log(data);
						//登录状态
						if(data.code == "1") {
							layar("停用成功");
							getList("", memTel, "", "", "", "", "", "", "")
						} else if(data.code == "-1") {
							layar(data.msg);
							setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
						} else {
							layar(data.msg);
						}
					},
					error: function(e) {
						errcode(e);
					}
				});
			});

		})
		$("#list-td").on("click", ".qiY", function() {
			var orderId = $(this).attr("id");
			layer.confirm('您确定启用吗？', {
				btn: ['确定', '取消'], //按钮
				offset: '25%'
			}, function(index) {
				$.ajax({
					url: "https://order.wz1996.wang/wzbg/order/reuse/" + orderId,
					type: 'put',
					beforeSend: function(request) {
						request.setRequestHeader("token", localStorage.getItem("token"));
					},
					contentType: 'application/json',
					success: function(data) {
						console.log(data);
						//登录状态
						if(data.code == "1") {
							layar("启用成功");
							getList("", memTel, "", "", "", "", "", "", "")
						} else if(data.code == "-1") {
							layar(data.msg);
							setTimeout("window.parent.frames.location.href='/xcxadmin/login.html'", 1000)
						} else {
							layar(data.msg);
						}
					},
					error: function(e) {
						errcode(e);
					}
				});
			});

		})
	</script>

</html>